1.log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell). 2.log4j:WARN Please initialize the log4j system properly. 3.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
package com.buwenbuhuo.hdfs;import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.junit.Test;import java.io.IOException; import java.net.URI; import java.net.URISyntaxException;/*** @author buwenbuhuo* @create 2020-04-22 16:45* com.buwenbuhuo.hdfs - the name of the target package where the new class or interface will be created.* hdfs0422 - the name of the current project.*/ publicclassHDFSClient{@TestpublicvoidtestMkdirs()throws IOException, InterruptedException, URISyntaxException {// 1 获取文件系统Configuration configuration =newConfiguration();// 配置在集群上运行FileSystem fs = FileSystem.get(URI.create("hdfs://hadoop001:9000"), configuration,"bigdata");// 2 创建目录fs.mkdirs(newPath("/0422/buwenbuhuo/test"));// 3 关闭资源fs.close();}}